﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Configuration;
using System.Data;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using Rison.Web.Common ;

namespace Rison.Web.CommonPage
{
    /// <summary>    
    /// 描述：客户端文件上传控件
    /// 功能：实现多文件上传和删除

    /// 作者：sfz
    /// 日期：2008-6-26
    /// </summary>
    public partial class ClientFileUploaderControl : UserControl 
    {
        private const string DEFAULT_BGCOLOR = "Transparent";
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }

        protected string UrlBase
        {
            get { return PageGlobalParams.PageUrlBase2; }
        }
       
        //要上传的文件集合
        public  List<HttpPostedFile> UploadingFiles
        {
            get 
            {
                List<HttpPostedFile> files = new List<HttpPostedFile>();
                
                for (int i = 0; i < this.Request.Files.Count; i++)
                {
                    string filename = this.Request.Files[i].FileName;

                    //只有当文件名不为空且Word文档才上传

                    //if (filename != string.Empty && (Path.GetExtension(filename).ToLower() == ".doc" || Path.GetExtension(filename).ToLower() == ".xls"))
                    //{
                        files.Add(this.Request.Files[i]);                        
                    //}
                }
                return files;
            }
        }

        //背景色

        private string _backgroundColor = "Transparent";
        public string BackgroundColor
        {
            get
            {
                return this._backgroundColor;
            }
            set
            {
                this._backgroundColor = value;
            }
        }

        //初始化的文件id（用“|”分隔的字符串）       
        public string InitFileIds
        {
            get
            {
                if (ViewState["InitFileIds"] != null)
                {
                    return ViewState["InitFileIds"].ToString();
                }
                else
                    return string.Empty ;
            }
            set
            {
                ViewState["InitFileIds"] = value;
            }
        }

        //初始化的文件显示名（用“|”分隔的字符串）
        //private string _initFileNames;
        public string InitFileNames
        {
            get
            {
                if (ViewState["InitFileNames"] != null)
                {
                    return ViewState["InitFileNames"].ToString();
                }
                else
                    return string.Empty;             
            }
            set
            {
                ViewState["InitFileNames"] = value;
            }
        }

        //服务器原有文件被删除记录
        public string DeleteFilesID
        {
            get
            {
                return this.hdnDeleteFiles.Value;
            }
        }

    }
}